package Gui;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JTextField;
import javax.swing.JLabel;
import javax.swing.JButton;

import Ctr.CtrStockLog;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class GuiStockControl extends JFrame {

	private JPanel contentPane;
	private JTextField textFieldEmployee;
	private JTextField textFieldProduct;
	private JTextField textFieldAmount;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					GuiStockControl frame = new GuiStockControl();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public GuiStockControl() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		textFieldEmployee = new JTextField();
		textFieldEmployee.setBounds(10, 75, 86, 20);
		contentPane.add(textFieldEmployee);
		textFieldEmployee.setColumns(10);
		
		JLabel lblGuiStockControl = new JLabel("Gui Stock Control");
		lblGuiStockControl.setBounds(10, 11, 86, 14);
		contentPane.add(lblGuiStockControl);
		
		JLabel lblEmployee = new JLabel("Employee");
		lblEmployee.setBounds(10, 50, 46, 14);
		contentPane.add(lblEmployee);
		
		JLabel lblProduct = new JLabel("Product");
		lblProduct.setBounds(10, 106, 46, 14);
		contentPane.add(lblProduct);
		
		textFieldProduct = new JTextField();
		textFieldProduct.setBounds(10, 131, 86, 20);
		contentPane.add(textFieldProduct);
		textFieldProduct.setColumns(10);
		
		JLabel lblAmount = new JLabel("Amount");
		lblAmount.setBounds(10, 162, 46, 14);
		contentPane.add(lblAmount);
		
		textFieldAmount = new JTextField();
		textFieldAmount.setBounds(10, 187, 86, 20);
		contentPane.add(textFieldAmount);
		textFieldAmount.setColumns(10);
		
		JButton btnOk = new JButton("OK");
		btnOk.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				
				int employeeID = Integer.parseInt(textFieldEmployee.getText().trim());
				int productID = Integer.parseInt(textFieldProduct.getText().trim());
				int amount = Integer.parseInt(textFieldAmount.getText().trim());
				CtrStockLog ctrsl = new CtrStockLog(productID, employeeID, amount);
			}
		});
		btnOk.setBounds(228, 117, 89, 23);
		contentPane.add(btnOk);
	}
}
